package com.example.homeworkmutualevaluation.Dao;

import com.example.homeworkmutualevaluation.Entity.PrimaryKey.SCPK;
import com.example.homeworkmutualevaluation.Entity.SC;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;


@Repository
public interface SCDao extends JpaRepository<SC, SCPK> {
    SC findBySphoneAndCno(String sphone, String cno);
    @Transactional
    @Modifying
    @Query(value = "INSERT INTO sc VALUES (?1, ?2)", nativeQuery = true)
    int insert(String sphone, String cno);
    @Transactional
    @Modifying
    @Query(value = "DELETE FROM sc WHERE `sphone`=?1 AND `cno`=?2", nativeQuery = true)
    int delete(String sphone, String cno);
    int countByCno(String cno);
}
